#ifndef _KALMANFILTER_H_
#define _KALMANFILTER_H_

#include <stdint.h>

typedef struct kalmanfilter_s
{
    /*过程噪声方差(数值很小，一般可为零)*/
    float q;
    /*测量噪声方差(在标准环境下测量，求取测量值的方差作为该值)*/
    float e_mea;
    /*估计值*/
    float x;
    /*估计误差方差(随意设置但不可为0，每次update会更新该值)*/
    float e_est;
    /*卡尔曼滤波增益(随意设置,取值范围0-1，每次update会更新该值)*/
    float k;
} kalmanfilter_t;

void kalmanfilter_init(kalmanfilter_t *kf, float q, float e_mea, float initial_value);
void kalmanfilter_predict(kalmanfilter_t *kf, volatile uint16_t *measurement);

#endif // KALMAN_FILTER_H
